'''
Created on 01/05/2010

@author: Mar
'''
from threading import Thread

class ThreadScreen(Thread):
    
    def __init__(self, queueScreen, aScreen, aReadyQ):
        Thread.__init__(self)
        self.queueScreen = queueScreen
        self.screen = aScreen
        self.readyQueue = aReadyQ
        
    def run(self):
        while (True):
            pcb = self.queueScreen.get()
            self.screen.executePCB(pcb)
            priority = pcb.getPriority()
            self.readyQueue.put((priority,pcb))
            if (len(pcb.program.instructions) == pcb.getPC()):
                pcb.toFinished() 